<?php
class user_UserMapper
{
	public function __construct()
	{
		$this->table = new tables_UserTable();
	}
	
	public function find($id)
	{
		$ut = new tables_UserTable();
		$userinfo = $ut->find($id)->current();
		$user = new user_User();
		$user->userId = $userinfo->id;
		$user->email = $userinfo->email;
		return $user;
		
	}
	
	public function save(user_User $user)
	{
		// UPDATE USER
		$data = array('email' => $user->email);
		$where = $this->table->getAdapter()->quoteInto('id = ?', $user->getId());
		return $this->table->update($data, $where);
	}
	
	/**
	 * create a new user in the database
	 *
	 * @param user_User $user
	 * @return unknown
	 */
	public function create(user_User $user)
	{
		$userTable = new tables_UserTable();
		$row = $userTable->createRow();
		$row->email = $user->email;
		return $row->save();
	}
}
?>